package com.dreamsky.life.interceptor;

import com.dreamsky.life.model.User;
import com.dreamsky.life.util.Const;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class LoginValidator extends Validator {

	@Override
	protected void validate(Controller controller) {
		validateString("user.user_name", 4, 18, "logerr",
				Const.LOGIN_NO_SUCCESS);
		validateString("user.user_pwd", 6, 18, "logerr", Const.LOGIN_NO_SUCCESS);

	}

	@Override
	protected void handleError(Controller controller) {

		controller.setAttr("success", false);
		controller.renderJson(new String[] { "success", "logerr" });
	}

}
